import React, { useState, useEffect, Suspense, lazy } from 'react';
import { Spin } from 'antd';

export default ({ compName, ...rest }) => {
  const [Component, SetComponent] = useState();

  useEffect(() => {
    switch (compName) {
      case '班级文化':
        SetComponent(lazy(() => import('../classCulture')));
        break;
      case '班级文化_中':
        SetComponent(lazy(() => import('../classCultureMediumSize')));
        break;
      case '班级考核积分':
        SetComponent(lazy(() => import('../classAssessRank')));
        break;
      case '一周班级积分':
        SetComponent(lazy(() => import('../classAssessTotal')));
        break;
      case '作业展示':
        SetComponent(lazy(() => import('../homework')));
        break;
      case '班级课表':
        SetComponent(lazy(() => import('../courseTable')));
        break;
      case '课外活动':
        SetComponent(lazy(() => import('../activity')));
        break;
      case '值日表':
        SetComponent(lazy(() => import('../dutyArrange')));
        break;
      case '学生素养榜':
        SetComponent(lazy(() => import('../studentRank')));
        break;
      case '优秀作品':
        SetComponent(lazy(() => import('../exhibition')));
        break;
      case '学生考勤':
        SetComponent(lazy(() => import('../attendance')));
        break;
      case '学生考勤_图':
        SetComponent(lazy(() => import('../attendanceChart')));
        break;
      case '校园动态_大':
        SetComponent(lazy(() => import('../campusActivity')));
        break;
      case '校园动态_中':
        SetComponent(lazy(() => import('../campusActivityMediumSize')));
        break;
      case '校园动态_小':
        SetComponent(lazy(() => import('../campusActivitySmallSize')));
        break;
      case '班级学生评价统计':
        SetComponent(lazy(() => import('../studentAssessReport')));
        break;
      case '班级学生评价统计_大':
        SetComponent(lazy(() => import('../studentAssessReport')));
        break;
      case '班级学生评价统计_小':
        SetComponent(lazy(() => import('../studentAssessReportSmallSize')));
        break;
      case '阅读统计':
        SetComponent(lazy(() => import('../readingStatistic')));
        break;
      case '小组积分统计':
        SetComponent(lazy(() => import('../groupScore')));
        break;
      default:
        SetComponent(lazy(() => import('./default')));
        break;
    }
  }, [compName]);

  return (
    <Suspense fallback={<Spin />}>
      {Component && <Component compName={compName} {...rest} />}
    </Suspense>
  );
};
